Skip to content

Fix issue #875: Reorder IfExp fields to match evaluation order#1441

Open
rylena wants to merge 1 commit intoInstagram:mainfrom
rylena:fix/issue-875-ifexp-order
Open

Fix issue #875: Reorder IfExp fields to match evaluation order#1441
rylena wants to merge 1 commit intoInstagram:mainfrom
rylena:fix/issue-875-ifexp-order

Conversation

@rylena
Copy link
Copy Markdown

@rylena rylena commented Feb 4, 2026

This PR fixes issue #875 by reordering the fields of IfExp to body, test, orelse.
This matches the Python syntax order (body if test else orelse) and the logical evaluation order.
Previously, the order was test, body, orelse, which caused repr(node) to be confusing and inconsistent with visitor order (which was already correct).

Changes:

  • Reordered IfExp fields in libcst/_nodes/expression.py.
  • Updated _visit_and_replace_children in IfExp to match new order.
  • Updated libcst/_nodes/tests/test_ifexp.py to use new field order in positional arguments.
  • Ran python -m libcst.codegen.generate all to update generated matchers and visitors.
  • Verified with reproduction script and existing tests.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant